
/**
 * 功能描述  导航条
 */
define(function (require, exports, module) {
	var Subnav = require("subnav");
	var aw = require("ajaxwrapper");
	var enmu = require("enums");
	var user = require("store").get("user");

	
    var instance = {
        initComponent: function (widget) {
        	var subnav = new Subnav({
        		parentNode: ".J-subnav",
        		model:{
        			title:"入住准备落实单",
        			items:[{
        				id:"search",
        				type:"search",
        				placeholder:"组团单位/目的地",
        				handler:function(str){
        					var grid=widget.get("grid");
        					aw.ajax({
        						url:"api/checkinimplement/search*",
        						data:{
        							s:str,
        							searchProperties:"nonMemGroupReserve.nonMemberGroup.servicePoint.name," +
        									"groupReserve.planItemGroup.planItem.destination.name," +
        									"groupReserve.planItemGroup.servicePoint.name," +
        									"groupReserve.planItemGroup.allianceOrg.name," +
        									"nonMemGroupReserve.nonMemberGroup.contactName,"+
        									"nonMemGroupReserve.nonMemberGroup.groupUnit",
        							fetchProperties:"pkCIImplement,version,roomStatus.*,status.*," +
        							"dataSource.*,signUpNum," + 
        							"nonMemGroupReserve.*,nonMemGroupReserve.nonMemberGroup," + 
        							"nonMemGroupReserve.nonMemberGroup.servicePoint.name," + 
        							"groupReserve.planItemGroup.allianceOrg.name," +
        							"nonMemGroupReserve.nonMemberGroup.contactName,"+
									"nonMemGroupReserve.nonMemberGroup.groupUnit,"+
        							"nonMemGroupReserve.nonMemberGroup.*," + 
        							"nonMemGroupReserve.nonMemberGroup.signUps.version," + 
        							"nonMemGroupReserve.nonMemberGroup.operator.servicePoint.name," + 
        							"groupReserve.planItemGroup.allianceOrg.name," +
        							"groupReserve.planItemGroup.allianceOrg.pkAllianceOrg," +
        							"groupReserve.signUpNumber," +
        							"groupReserve.checkInDate," +
        							"groupReserve.checkOutDate," +
        							"groupReserve.planItemGroup.planItem.destination.name," +
        							"groupReserve.planItemGroup.signUps.version," +
        							"groupReserve.roomRegisters.pkRoomRegister," +
        							"groupReserve.roomRegisters.room.code," +
        							"groupReserve.roomRegisters.room.orgBuilding.name," +
        							"groupReserve.planItemGroup.servicePoint.pkServicePoint," +
        							"groupReserve.planItemGroup.servicePoint.name," +
        							"checkInCar.pkCheckInCar," + 
        							"checkInCar.version," +
        							"checkInCar.haveCar," +
        							"checkInCar.address," + 
        							"checkInCar.status," +
        							"checkInCar.description," +
        							"checkInCar.address," +
        							"checkInCar.carDate," +
        							"checkInDinner.pkCheckInDinner," +
        							"checkInDinner.version," + 
        							"checkInDinner.haveDinner," +
        							"checkInDinner.breakfast," +
        							"checkInDinner.lunch," +
        							"checkInDinner.supper," +
        							"checkInDinner.status," +
        							"checkInDinner.description"
        						},
        						dataType:"json",
        						success:function(data){
        							grid.setData(data);
        						}
        					});
        				}
        			},{
        				id:"servicePoint",
        				type:"buttongroup",
//        				lazy: true,
        				tip:"服务点",
        				keyField :"pkServicePoint",
					    valueField : "name",
					    items:user.privateServicePoints,
//					    url : "api/servicepoint/operableservicepoints",
					    handler : function(key,element){
					    	widget.get("grid").refresh();
					    }
        			},{
        				id:"status",
        				tip: "状态",
        				type:"buttongroup",
        				items:[{
        					key: "Initial",
        					value: "初始"
        				},{
        					key: "Edited",
        					value: "已设置"
        				},{
        					key: "Doing",
        					value: "准备中"
        				},{
        					key: "Confirmed",
        					value: "已落实"
        				}],
        				all : {
							show:true,
							position:"bottom"
						},
						tip:"状态",
						handler : function(key,element){
					    	widget.get("grid").refresh();
					    }
        			},{
        				id:"startDate",
        				tip: "入住日期",
        				type:"daterange",
        				ranges: {
        					 "本月": [moment().startOf("month"), moment().endOf("month")]
			            },
			            defaultRange: "本月",
        				handler : function(time){
							widget.get("grid").refresh();
						}
        			},{
        				id:"save",
        				type:"button",
        				text:"保存",
        				show:false,
        				handler:function(){
        					widget.handler.subnav.handleSaveBtnClick(widget);
        				}
        			},{
        				id:"cancel",
        				type:"button",
        				text:"返回",
        				show:false,
        				handler : function(){
        					widget.get("grid").refresh();
        					widget.hide([".J-tab"]).show([".J-grid"]);
        					widget.get("subnav").hide(["save", "cancel"]).show(["servicePoint","status","startDate","search"]);
        				}
        			},{
        				id:"set",
        				type:"button",
        				text:"设置",
        				show:false,
        				handler:function(){
        					aw.ajax({
        						url:"api/groupreserve/query",
        						data:{
        							"pkGroupReserve": pkGroupReserve,
        							fetchProperties:"pkGroupReserve,roomRegisters.pkRoomRegister," +
        									"roomRegisters.room.orgBuilding.name," +
        									"roomRegisters.room.code"
        						},
        						dataType:"json",
        						success:function(data){
        							widget.show([".J-tab"]).hide([".J-grid"]); 
        	  						widget.get("subnav").show(["save","cancel"]).hide(["startDate","search","status","servicePoint","set"]);
        						}
        					});
        				}
        			}]
        		}
        	});
            widget.set("subnav",subnav);
        }
    };
    module.exports = instance;
});
